package com.sikaryofficial.backend.manager.information;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sikaryofficial.backend.domain.dto.req.information.TopicListReq;
import com.sikaryofficial.backend.domain.dto.resp.information.TopicBackendDTO;
import com.sikaryofficial.backend.domain.dto.resp.information.TopicDTO;
import com.sikaryofficial.backend.service.IArticleService;
import com.sikaryofficial.backend.service.IFollowService;
import com.sikaryofficial.common.security.utils.SecurityUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author : qinjinyuan
 * @desc : 文章分类服务
 * @date : 2024/04/10 10:46
 */
@Component
@Slf4j
public class TopicManager {
    @Autowired
    private IArticleService articleService;

    /**
     * 查询分页列表
     *
     * @param req
     * @return
     */
    public IPage<TopicDTO> listPage(TopicListReq req) {
        Page<TopicDTO> customerPage = new Page<>(req.getPageNum(), req.getPageSize());
        // 未删除 && 审核通过  && 排序： 创建时间 和 阅读量
        req.setUserId(SecurityUtils.getUserId());
        return articleService.topicList(customerPage, req);
    }

    public IPage<TopicBackendDTO> listBackendPage(TopicListReq req) {
        Page<TopicBackendDTO> customerPage = new Page<>(req.getPageNum(), req.getPageSize());
        // 未删除 && 审核通过 && 排序：是否选中为tag 创建时间 和 阅读量
        return articleService.topicBackendList(customerPage, req);
    }

}